var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
var logger = require('morgan');
const bodyParser = require('body-parser');

// 导入cors包
const cors = require('cors');

const userRouter = require('./routes/gg_user');
const noticeRouter = require('./routes/gg_notice');
const reportRouter = require('./routes/gg_report');
const auditEventRouter = require('./routes/gg_auditEvent');

var app = express();
// 增大可传递的数据大小值
app.use(bodyParser.json({ limit: '50mb' }));
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));

//静态伺服
app.use(express.static('page'));

// 注册全局中间件
app.use(cors());
app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

//
app.use('/user', userRouter);
app.use('/notice', noticeRouter);
app.use('/report', reportRouter);
app.use('/auditEvent', auditEventRouter);

module.exports = app;
